-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Better versioned history #209
ENH Better versioned history #209
Conversation
b7eab31
to
acbbed5
Compare
@@ -5,7 +5,6 @@ import { connect } from 'react-redux'; | |||
import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'; | |||
import { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'; | |||
import { restrictToVerticalAxis, restrictToParentElement } from '@dnd-kit/modifiers'; | |||
import { injectGraphql } from 'lib/Injector'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is unrelated refactoring to remove an unused import
*/ | ||
const LinkField = ({ | ||
value = null, | ||
onChange, | ||
onNonPublishedVersionedState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is unrelated refactoring to remove a non-existent prop
setLoading(false); | ||
// isSorting is set to true on drag start and only set to false here to prevent | ||
// the loading indicator for flickering | ||
setIsSorting(false); | ||
}) | ||
.catch(() => { | ||
actions.toasts.error(i18n._t('LinkField.FAILED_TO_LOAD_LINKS', 'Failed to load links')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to not show a red toast here because this will pop up when viewing old versions of an owner where the link has been deleted. I've changed this to show an inline message when the link fails to load.
@@ -350,7 +362,7 @@ const LinkField = ({ | |||
|
|||
LinkField.propTypes = { | |||
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]), | |||
onChange: PropTypes.func.isRequired, | |||
onChange: PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never have been a required field as it only makes sense in an entwine context
@@ -23,6 +23,7 @@ const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onC | |||
// which will causes bugs with validation | |||
if (!LinkModal) { | |||
setLinkModal(() => loadComponent(`LinkModal.${handlerName}`)); | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should is to fix a console error where the state hasn't yet been updated from the call the setLinkModal, meaning that the <LinkModal>
jsx object doesn't yet exist at time of render because LinkModal hasn't yet been set. Setting the state via this hook will trigger a rerender in which time <LinkModal>
will not exist
@@ -21,7 +21,7 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') { | |||
"LinkField.LINK_MODIFIED_TITLE": "Link has unpublished changes", | |||
"LinkField.LINK_MODIFIED_LABEL": "Modified", | |||
"LinkField.CANNOT_CREATE_LINK": "Cannot create link", | |||
"LinkField.FAILED_TO_LOAD_LINKS": "Failed to load links", | |||
"LinkField.FAILED_TO_LOAD_LINKS": "Failed to load link(s)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor improvement to the message as it's used for both LinkField and for MultiLinkField
*/ | ||
const LinkField = ({ | ||
value = null, | ||
onChange, | ||
onNonPublishedVersionedState, | ||
onChange = () => {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a default value that's being set now that it's no longer a required prop
@@ -66,16 +76,21 @@ test('LinkField will render loading indicator if ownerID is not 0', async () => | |||
expect(container.querySelectorAll('.link-picker')).toHaveLength(1); | |||
}); | |||
|
|||
test('LinkField will render link-picker if ownerID is not 0 and has finished loading', async () => { | |||
test('LinkField will render link-picker if ownerID is not 0 and isMulti and has finished loading', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This jest test was technically wrong before - it shouldn't render a .link-picker
element if it's non-isMulti and ownerID is not 0 - it should only render that if it's isMulti
1d6eb0b
to
2d01f5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to fulfil this acceptance critera (or deem it too hard for this card and open a separate card for them):
Archived Admin uses the same behaviour as Versionned Admin when displaying link.
If I click on an archived page from archive admin, I see:
Note that there was a link in both the "Has one link" and "Has many links one" field, but not the "Has many links two" field.
LinkField on versioned history view correctly identify if a Link was attached to the page, but the Link was deleted.
This doesn't seem to work.
- Create a link on a page
- Publish the page
- Archive the link
- Make a change to the page and publish it again
- View the version of the page which did have the link
For me it shows "Failed to load link(s)"
Issue with archived history
When I archive a page (which has links on it), then restore the page from archived, then in the history tab I try to view the archive version, I get an infinite loading component.
2d01f5b
to
be97b78
Compare
ArchivedAdmin support adds a level of complexity over the regular history viewer that I don't think is worth it. We need to support multiple permutations of owner and links archived and not-archived. The LinkFieldController which handles all the data isn't aware of this. We also need to add support for knowing if we're even in an archived admin which is very messy because of the special treatment given to SiteTree vs other dataobjects.
This relates to the point above. Because the link was deleted then when attempting to fetch the link via LinkFieldController it will return a 404. We could change the message from "Failed to load link(s)" to "Link was deleted" ... but then again that's an assumption because it may be 404'ing for a different reason. I'd say it's such a minor point we should just leave as is.
I was unable to replicate this issue |
be97b78
to
6e25096
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, definitely an improvement over how it was before. Just a bit of tidy up.
eace65b
to
79e6307
Compare
79e6307
to
e3871a4
Compare
e3871a4
to
3e97f0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue #10
May require silverstripe/silverstripe-versioned-admin#198 to be merged in order for archive admin to work properly
Note that for elemental page history where you have block with a has_one linkfield on it, the value for this nested field will not display. This is consistent with nested file's not showing on the history of an elemental-file-block with a linked file on it which also does not show on the page history. In both instances, clicking on the "Block history" link will show the value of nested field